<template>
  <div class="home">
    <button @click="insertUser" type="success">添加用户</button>
    <button @click="deleteUser" type="danger">删除用户</button>
    <button @click="selectUser" type="info">查询用户</button>
    <button @click="updateUser" type="primary">修改用户</button>
    <button @click="exportUser" type="warning">导出用户</button>
    <button @click="logoutUser" type="info">退出登录</button>
  </div>
</template>

<script>

export default {
  name: 'HomeView',
  components: {
  },
  methods:{
    insertUser() {
    this.$http.get("/user/insert")
    },
    deleteUser() {
      this.$http.get("/user/delete")
    },
    selectUser() {
      this.$http.get("/user/select")
    },
    updateUser() {
      this.$http.get("/user/update")
    },
    exportUser() {
      this.$http.get("/user/export")
    },
    //退出
    logoutUser(){
       this.$http.post("/logout").then(res=>{
            sessionStorage.removeItem("token")
            //跳转到登录页面
            this.$router.push("/login")
       })
    },
  }
    
}
</script>
